<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>更多数据</title>
    <link rel="stylesheet" type="text/css" href="<%=path %>/resource/lib/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link rel="stylesheet" type="text/css" href="<%=path %>/resource/lib/ligerUI/skins/sqBlue/css/all.css">
    <link rel="stylesheet" type="text/css" href="<%=path %>/resource/lib/ligerUI/skins/sqBlue/css/sq-sj.css">
    <jsp:include page="../../../import.jsp" flush="true"/>
    <style type="text/css">
        .l-text-wrapper{
            display: inline-block;
        }
        .l-form div.btnsBox{
            text-align: left;
        }
        .l-form div.btm{
            padding: 0;
        }
        .form_view{
            padding: 10px 0;
        }
    </style>
    <script src="<%=path %>/resource/lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="<%=path %>/resource/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
    <script src="<%=path %>/resource/lib/sq.all.js" type="text/javascript"></script>
    <script type="text/javascript">
        var form=null,formData=null, data=null,dayRegionNum=null,dayRegion=null,dateMin=null,dateMax=null;
        var dayRegion1 = null;
        $(function () {
        	form = $("#searchBar").ligerForm();
            formData = form.getData();
        	
            _url='<%=path%>/mongo/storeStats/moreMessage.do';
        	$("#ligergrid1").ligerGrid({
    	    	url :_url,
    	    	method : 'post',
    	    	columns: [
    	    	          { display: '用户ID', name: 'id', minWidth: 60},
    	    	         /*  { display: '用户IP', name: 'usrIp', minWidth: 60}, */
    	    	          { display: '手机号', name: 'tel', minWidth: 60},
    	    	          { display: '所属经销商', name: 'splNm', minWidth: 60},
    	    	          { display: '用户注册时间', name: 'crtTm', minWidth: 60,
    	    	        	  render: function(rowdata, rowindex, value){
    	    	        		 return  renderDate2(rowdata, rowindex, value);
    	    	        		},
    	    	          },
    	    	          { display: '是否实名', name: 'isAutonym', minWidth: 60,
    	    	        	  render: function(rowdata, rowindex, value){
    	    	        		  if(rowdata.isAutonym == 1){
    	    	        			  return "是";
    	    	        		  }else{
    	    	        			  return "否";
    	    	        		  }
    	    	        		  
    	    	        		},
    	    	          },
    	    	          { display: '最近一次打开APP时间', name: 'actionDt', minWidth: 60,
    	    	        	  render: function(rowdata, rowindex, value){
     	    	        		 return renderDate2(rowdata, rowindex, value)  
     	    	        		},  
    	    	          },
    	    	 	],
    	    	 	pageSize:20,
    		        root:'rows',
    		        record:'total',
    		        hideLoadButton : true,
    		        width: '100%',
    		        height:'100%',
    		        heightDiff:-2,
    		        checkbox:true,
    		        fixedCellHeight: false,
    		        rownumbers:true,
    	    });
        	grid = liger.get("ligergrid1");
        	
        	$("#clearBtn").click(function (){
        		clearLigerForm("searchBar");
                dayRegionNum = null; 
            })
        });

        /**
         * 查询最近几天的统计情况
         * @param dayRegion
         * */
        function getAppStatsDataInfo(_dayRegion){
            if(!_dayRegion){
               $.ligerDialog.SQalert({content:"查询最近几天的数据参数不能为空！", SQ_type: "error"});
               return ;
            }
            dayRegionNum = _dayRegion;
            form = liger.get("searchBar");
            var formData = form.getData();
            formData['dayRegion'] = _dayRegion ;
            console.log(JSON.stringify(formData));
            for (name in formData){
	            grid.setParm(name,formData[name]);
	         };
            grid.reload();
            
        }
       	function searchBtn(){
       		form = liger.get("searchBar");
            var formData = form.getData();
            formData['dayRegion']=dayRegion1;
            console.log(JSON.stringify(formData));
            for (name in formData){
	            grid.setParm(name,formData[name]);
	         };
            grid.reload();
       	}
       	
       	function renderDate2(rowdata, index, value) {
			var dateStr = "";
			if (null != value) {
				var date = new Date(value);
				dateStr = DateUtils.formatDate(date, "yyyy-MM-dd hh:mm");
			}
			return dateStr;
		}
       	
       	
      //导出
        function exportMoreMessages(){
        	//alert("导出表格")
        	var form = liger.get("searchBar");
            var data = form.getData();
            if(dayRegionNum){
                data['dayRegion'] = dayRegionNum ;
            }
            console.log(JSON.stringify(data));
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType:'json',
                url: '<%=path%>/mongo/storeStats/exportMoreMessages.do',
                data:data,
                beforeSend:function(){
                    wait_dialog=$.ligerDialog.SQalert({content: '导出数据中...',SQ_type: "waitting"});
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        //window.open(msg.data);
                        console.log(msg.data);
                        window.location.href = msg.data;
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });

    };
    
    
   
</script>

</head>
<body class="iframeBody">
<div class="Wrapper">
    <div class="index_content">
        <div class="passageway">
            <div class="form_view">
                <form id="searchBar">
                    <div class="fieldset1 clearFix">
                        <div class="btnsBox">
                            <span id="yBtn" class="sq-button sq-button-round" onclick="javaScript:getAppStatsDataInfo('1');">昨天</span>
                            <span id="sBtn" class="sq-button sq-button-round" onclick="javaScript:getAppStatsDataInfo('7');">近7天</span>
                            <span id="fBtn" class="sq-button sq-button-round" onclick="javaScript:getAppStatsDataInfo('15');">近15天</span>
                            <span id="tBtn" class="sq-button sq-button-round" onclick="javaScript:getAppStatsDataInfo('30');">近30天</span>
                        </div>
                        <div class="sqPanel_body">
                            <div class="fieldBox">
                                <div class="label">自定义时间设置</div>
                                <div class="field">
                                    <input name="dateMin" id="dateMin" type="text" class="ui-datepicker" value="" >
                                     - 
                                    <input name="dateMax" id="dateMax" type="text" class="ui-datepicker" value="">
                                </div>
                            </div>
                        </div>
                        <div class="btnsBox btm">
                            <span id="searchBtn" class="sq-button sq-button-round" onclick="javascript:searchBtn();">查询</span>
                            <%--<span id="detailBtn" class="sq-button sq-button-round" onclick="javascript:exportMoreMessages();">导出表格</span> --%>
                            <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                        </div>
                    </div>
                </form>
            </div>
            
            <div id="ligergrid1" class="sq-grid"></div>
        </div>
    </div>
</div>
</body>


</html>